#include "FunctionList.h"

#include "Function.h"
#include "NativeFunction.h"

CFunction *CFunctionList::FindFunction(const CString &InFunctionName)
{
    for(CFunction* Function : Functions)
    {
        if(Function->Name==InFunctionName)
        {
            return Function;
        }
    }

    if(ParentType->BaseType && ParentType->BaseType->Functions )
    {
        return ParentType->BaseType->Functions->FindFunction(InFunctionName);
    }   
    return nullptr;
}

CFunction *CFunctionList::FindNativeFunction(int64_t NativeFunctionPtr)
{
    for(CFunction* Function : Functions)
    {
        if(Function->IsNative())
        {
            CNativeFunction* NativeFunction = static_cast<CNativeFunction*>(Function);
            if(NativeFunction->NativeFunctionPtr==NativeFunctionPtr)
            {
                return Function;
            }
        }
    }

    if(ParentType->BaseType && ParentType->BaseType->Functions )
    {
        return ParentType->BaseType->Functions->FindNativeFunction(NativeFunctionPtr);
    }   
    return nullptr;

}
